//
//  ShowApplyViewController.m
//  CommunityNannyO2O
//
//  Created by 90 on 15/7/21.
//  Copyright (c) 2015年 Apple. All rights reserved.
//

#import "ShowApplyViewController.h"
#import "AppConfig.h"
#import "QXNetWorkTool.h"
#import "APIAdress.h"
#import "MBProgressHUD+YC.h"
#import "MJExtension.h"
#import "AccountTool.h"
#import "ShowApplyVideoViewCell.h"
#import "ShowApplyAudioViewCell.h"
#import "ShowApplyImageViewCell.h"
#import "ShowApplyViewCell0.h"
#import "AudioApplyViewController.h"
#import "VideoApplicationViewController.h"
#import "UserDataSingleton.h"
#import "ImageTextViewController.h"
#import "MusicApplicationViewController.h"

@interface ShowApplyViewController()<QXNetWorkToolDelegate,
        UITableViewDataSource,UITableViewDelegate,
        ShowApplyVideoViewCellDeletage,ShowApplyAudioViewCellDeletage,ShowApplyImageDeletage>
{

}

@property (weak, nonatomic) IBOutlet UITableView *tableView;

@end


@implementation ShowApplyViewController

- (void)viewDidLoad
{
    [super viewDidLoad];
    
    self.tableView.dataSource = self;
    
    self.tableView.delegate = self;
    
    self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone;

}

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
    
    return 1;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return 3;
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    if (indexPath.row == 0)
    {
        return 147;
    }
    return 96;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    
    if (indexPath.row == 0)
    {
        ShowApplyViewCell0 *cell = [ShowApplyViewCell0 cellWithTableView:tableView];
        
        return cell;
    }
    else if (indexPath.row == 1)
    {
        ShowApplyVideoViewCell *cell = [ShowApplyVideoViewCell cellWithTableView:tableView];
        cell.videoDelegate = self;
        
        return cell;
    }
//    else if (indexPath.row == 2)
//    {
//        ShowApplyAudioViewCell *cell = [ShowApplyAudioViewCell cellWithTableView:tableView];
//        cell.audioDelegate = self;
//        
//        return cell;
//    }
    else if (indexPath.row == 2)
    {
        ShowApplyImageViewCell *cell = [ShowApplyImageViewCell cellWithTableView:tableView];
        cell.deletage = self;
        
        return cell;
    }
    
    UITableViewCell *cell = [[UITableViewCell alloc] init];
    
    return cell;
}

//视频
-(void)showVideo
{
    UserDataSingleton *userData = [UserDataSingleton shareInstance];
    if(![userData isLogin])
    {
        [userData pleaseLogin:self];
        return;
    }
    
    VideoApplicationViewController *videoApplicationViewController = [VideoApplicationViewController create];
    
    [self.navigationController pushViewController:videoApplicationViewController animated:YES];
}

-(void)showImage
{
    UserDataSingleton *userData = [UserDataSingleton shareInstance];
    if(![userData isLogin])
    {
        [userData pleaseLogin:self];
        return;
    }
    
    ImageTextViewController *imageTextViewController = [ImageTextViewController create];
    
    [self.navigationController pushViewController:imageTextViewController animated:YES];
}

//音频添加
-(void)showAudio
{
    UserDataSingleton *userData = [UserDataSingleton shareInstance];
    if(![userData isLogin])
    {
        [userData pleaseLogin:self];
        return;
    }
    
//    AudioApplyViewController *obj = [AudioApplyViewController create];
//    obj.applyType = EAudioApply;
    MusicApplicationViewController *musicApplicationViewController = [MusicApplicationViewController create];
    
    [self.navigationController pushViewController:musicApplicationViewController animated:YES];
}

-(void)configNavigationItem
{
    self.navigationItem.title = @"展示申请";
    [self.navigationController.navigationBar setTranslucent:NO];
    
    [self.navigationController.navigationBar
     setBackgroundImage:[UIImage imageNamed:@"bg_navigation_bar"]
     forBarMetrics:UIBarMetricsDefault];
    
    //status bar的字体为白色
    //导航栏的背景色是黑色
    self.navigationController.navigationBar.barStyle = UIBarStyleBlack;
    
    [self.navigationController.navigationBar setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:[UIColor whiteColor],NSForegroundColorAttributeName, [UIColor colorWithRed:0.0 green:0.0 blue:0.0 alpha:1.0],UITextAttributeTextShadowColor,[UIFont fontWithName:@"Hiragino Sans GB" size:18.0],NSFontAttributeName,nil]];
    
    [self configNavigationBackAction:^{
        
        [self.navigationController popViewControllerAnimated:YES];
    }];
    
//    [self configNavigationRightItemWith:[UIImage imageNamed:@"ico_show_apply_application"] andAction:^{
//        
//    }];
}

-(void)useMethodToFindBlackLineAndHind
{
    UIImageView* blackLineImageView = [self findHairlineImageViewUnder:self.navigationController.navigationBar];
    
    blackLineImageView.hidden = YES;
}

-(void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];

    [self configNavigationItem];

    [self useMethodToFindBlackLineAndHind];
}

-(void)viewWillDisappear:(BOOL)animated
{

}


@end









